package com.zhihaoliang.coroutine.util

import android.util.Log
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.Job
import kotlin.coroutines.CoroutineContext


fun log(msg: Int, coroutine: CoroutineContext? = null) {
    log("$msg", coroutine)
}

fun log(msg: String?, coroutine: CoroutineContext? = null) {
    val message = msg ?: "null"
    if (coroutine == null) {
        Log.e("~~~~", "${Thread.currentThread()} : $message")
    } else {
        val tag = "${Thread.currentThread()}-->${coroutine[Job]}-->${coroutine.hashCode()}-->${coroutine[CoroutineName.Key]} :"
        Log.e("~~~~", "$tag $message")
    }
}

